package com.palrevo.beackBeans.admin;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import com.palrevo.controllers.NavigationController;
import com.palrevo.controllers.NavigationRule;

import com.palrevo.beackBeans.BeansBase;
import com.palrevo.data.dao.DataException;
import com.palrevo.data.models.Program;
import com.palrevo.data.services.ProgramsDBService;


@ManagedBean(name="programsAdminBean")
@SessionScoped
@SuppressWarnings("serial")
public class ProgramsAdminBean extends BeansBase {

	private List<Program> programsList;
	private Program program;
	
	/**
	 * 
	 * @throws DataException
	 */
	public void loadProgramsList(){
		try {
			programsList = ProgramsDBService.getInstance().loadAllPrograms();
		} catch (DataException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		NavigationController.navigate(NavigationRule.PROGRAMS_SUMMARY);
	}
	
	public void viewProgramDetails(Program prog){
		try {
			program = ProgramsDBService.getInstance().getProgramDetails(prog.getId());
		} catch (DataException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		NavigationController.navigate(NavigationRule.PROGRAM_DETAILS);
	}

	/**
	 * 
	 * @return
	 */
	public List<Program> getProgramsList() {
		return programsList;
	}

	/**
	 * 
	 * @param programsList
	 */
	public void setProgramsList(List<Program> programsList) {
		this.programsList = programsList;
	}

	public Program getProgram() {
		return program;
	}

	public void setProgram(Program program) {
		this.program = program;
	}
	
}
